// 方式一
// 滑动窗口
// 时间：96ms - 21%
var searchRange = function(nums, target) {
  let start = 0;
  let end = nums.length - 1;
  let startStop = false;
  let endStop = false;
  while (start <= end && (!startStop || !endStop)) {
    if (nums[start] < target) {
      start = start + 1;
    } else if (nums[start] === target) {
      startStop = true;
    }
    if (nums[end] > target) {
      end = end - 1;
    } else if (nums[end] === target) {
      endStop = true;
    }
  }
  if (startStop && endStop) {
    return [start, end];
  }
  return [-1, -1];
};

console.log(searchRange([5, 7, 7, 8, 8, 10], 10));
